import React from 'react';
import * as asyncLoad from '../util/asyncLoad';
import { workflowPublicFiles } from '../constants/fileConfig';
import Loading from './Loading';

export default class ForwardBack extends React.Component{

    constructor(){
        super();
        this.state = {hasLoad: false};
    }

    componentDidMount(){
        const init = () =>{
            const { WfForwardBackStore } = window.weaWorkflowPublic;
            const store = new WfForwardBackStore();
            this.setState({hasLoad: true,store:store});
        }
        asyncLoad.asyncLoadModule('workflowPublic', workflowPublicFiles, init);
    }
    render(){
        const { hasLoad ,store} = this.state;
        if(hasLoad){
            const { visible,requestid,callBackActions } = this.props;
            store.setShowForwardBack(visible,requestid);
            store.setCallBackAction(callBackActions);
            const { WfForwardBack} = window.weaWorkflowPublic;
            return (<WfForwardBack ecId={`${this && this.props && this.props.ecId || ''}_WfForwardBack@81r7bw`} wfForwardBackStore={store}/>);
        }else{
            return (<Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@gtf35n`} />);
        }
    }
}